package com.xbts.system.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import javax.swing.tree.TreeNode;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.Data;
import com.xbts.common.annotation.Excel;
import com.xbts.common.utils.StringUtils;
import com.xbts.common.core.domain.BaseEntity;
import sun.security.x509.GeneralSubtree;

import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;

/**
 * 帮助中心对象 cnHelp
 *
 * @author xbts
 * @date 2023-08-03
 */
@Data
@ApiModel("帮助中心对象")
@TableName("cn_help")
public class CnHelp extends BaseEntity {

    private static final long serialVersionUID=1L;

    /** 帮助中心主键 */
    @TableId
    private String helpId;

    /** 帮助名称*/
    @Excel(name = "帮助名称")
    @ApiModelProperty("帮助名称")
    @NotEmpty(message = "帮助名称不能为空")
    private String helpName;

    /** 帮助中心父级id */
    @Excel(name = "帮助中心父级id")
    @ApiModelProperty("帮助中心父级id")
    @NotNull(message = "帮助中心父级id不能为空")
    private String helpParentId;

    /** 帮助内容 */
    @Excel(name = "帮助内容")
    @ApiModelProperty("帮助内容")
    private String content;

    /** 子集 */
    @Excel(name = "子集")
    @ApiModelProperty("子集")
    @TableField(exist = false)
    private List<CnHelp> children;

    /** 排序 */
    @Excel(name = "排序")
    @ApiModelProperty("排序")
    private String sort;

    /**
     * 1分类 2内容
     */
    private Integer type;

    public<T> QueryWrapper<T> queryWrapper(){
        QueryWrapper<T> queryWrapper=new QueryWrapper<>();
        queryWrapper.like(StringUtils.isNotEmpty(helpName),"help_name",helpName);
        queryWrapper.eq(!Objects.isNull(helpParentId),"help_parent_id",helpParentId);
        return queryWrapper;
    }
}